const mongoose = require('./db')
var Schema = mongoose.Schema
// 设备表
let deviceSchema=new Schema({
    deviceimg:String,//设备图片
    deviceModel:String ,//设备型号
    size:Number,//存储空间
    waterproof:String,//防水级别
    quality:String, //质量
    maintenance:Number, //保修期限
    num:{
        type:Number,
        default:1
    },//数量
    price:Number,//价格
    deviceKinds_id:{
        type:mongoose.Types.ObjectId,
        ref:"device_kinds"
    },
    deviceStatus:Number //运行状态 运行中 1 已关机 2 故障中
})
// 设备分类表
let device_kindSchema=new Schema({
    device_name:String
})
// 设备管理表
let deviceAdminSchema=new Schema({
    device_id:{
        type:mongoose.Types.ObjectId,
        ref:"devices"
    },
    year:Number,
    begin_time:Date,
    end_time:Date,
    leaseStatus:{
        type:Number,
        default:0
    },
    position:String,
    capacity:{
        type:Number,
        default:0
    },
    runningState:{
        type:Boolean,
        default:false
    },
    revorname:String,
    phone:String,
    address:String,
    serve:{
        type:Boolean,
        default:true
    },
    content:String,
    num:Number
})
let devicesModel=mongoose.model('devices',deviceSchema,'devices')
let device_kindModel=mongoose.model('device_kinds',device_kindSchema,'device_kinds')
let deviceAdminModel=mongoose.model('deviceAdmin',deviceAdminSchema,'deviceAdmin')
module.exports = {devicesModel,device_kindModel,deviceAdminModel}
